<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>垫款单明细列表</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<script type="text/javascript">
	var grid = null;

	$(function () {

        $("#tsxdht").bind("click",function(){
            pushContract();
        });
        $("#cstswj").bind("click",function(){
            pushQuestionnaire();
        });
        //更新测算结果
		$("#gxdkcsjg").bind("click",function(){
            updateCalcrstCd();
		});
		
		var _url = '<%=path%>/dk/dkbilldtl/initList.do?billId=${billId}' ;
	    grid = $("#ligergrid1").ligerGrid({
	    	url: _url,
	    	method : 'get',
	        columns: [
                { display: '支付表编号', align:'left', width: 80,
                    render: function (rowdata, rowindex, value){
                        return rowdata.paySchNo;
                    }
                },
                { display: '状态', width: 50,name: 'dtlStsCd',
                    render: function (rowdata, rowindex, value){
                       return rowdata.prdStsCd;
                    }
                },
                { display: '逾期天数', align:'left', width: 50,
                    render: function (rowdata, rowindex, value){
                        return rowdata.overdueDay;
                    }
                },
                { display: '逾期金额', align:'left', width: 100,
                    render: function (rowdata, rowindex, value){
                        return rowdata.overdueAmountYuan;
                    }
                },
                { display: '问卷结果', align:'left', width: 100,
                    render: function (rowdata, rowindex, value){
                        var qtnRstCd = rowdata.qtnRstCd;
                        return qtnRstCd;
                    }
                },
                { display: '垫款测算结果', align:'left', width: 100,
                    render: function (rowdata, rowindex, value){
                        var calcRstCd = rowdata.calcRstCd;
                        return calcRstCd;
                    }
                },
                { display: '预计垫款/赎回金额', align:'left', width: 50,
                    render: function (rowdata, rowindex, value){
                        return rowdata.estimateRedeemAmtYuan;
                    }
                },
                { display: '垫款合同签署状态', align:'left', width: 100,
                    render: function (rowdata, rowindex, value){
                        var signStsCd =  rowdata.signStsCd;
                        return signStsCd;
                    }
                },
                { display: '推送时间',name:'pushTm', align:'left', width: 100,
                    render: function (rowdata, rowindex, value){
                        return renderDate2(rowdata, rowindex, value);
                    }
                },
                { display: '签署时间',name:'pushTm', align:'left', width: 100,
                    render: function (rowdata, rowindex, value){
                        return renderDate2(rowdata, rowindex, value);
                    }
                },
                { display: '垫款状态', width: 50,name: 'dtlStsCd',
                    render: function (rowdata, rowindex, value){
                        var dtlStsCd = rowdata.dtlStsCd;
                        return dtlStsCd;
                    }
                },
                { display: '小贷账单编号', align:'left', width: 50,
                    render: function (rowdata, rowindex, value){
                        return rowdata.contNo;
                    }
                },
                { display: '实际垫款/赎回金额', align:'left', width: 150,
                    render: function (rowdata, rowindex, value){
                        return rowdata.actualRedeemAmtYuan;
                    }
                }
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-2,
	        fixedCellHeight: false,
	        rownumbers:true
	    });
	    grid = liger.get("ligergrid1");
	    grid.setHeight(100);
	    $("#searchBar").ligerForm();
	
	    $("#searchBtn").click(function(event) {
	         var form = new liger.get("searchBar");
	         var data = form.getData();
	         console.log(JSON.stringify(data));
	         for (name in data){
	            grid.setParm(name,data[name]);
	         };
	        grid.reload();
	    });
	    
	    $("#clearBtn").click(function(event) {
	        $("#resetBtn").click();  //重置 input-text
	        var form = liger.get("searchBar");
	        form.setData({  //重置select等特殊表单
	            "qtnRstCd": " ",
	            "calcRstCd": " ",
                "signStsCd": " ",
                "dtlStsCd": " "
	        });
	    });
		
	});

    /**
     *  推送小贷合同
     */
    function pushContract(){
        var url = '<%=path%>/dk/dkbilldtl/pushContract.do';
        var billId = '${billId}';
        $.ajax({
            type: 'get',
            dataType:'json',
            data: {billId:billId},
            url: url,
            success:function(msg){
                if(msg.success == '1'){
                    $.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
                    grid.reload();
                }else{
                    $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
                }
            }
        });
    }
    
	function pushQuestionnaire(){
			var url = '<%=path%>/dk/dkbilldtl/pushQuestionnaire.do';
	        var billId = '${billId}';
	        $.ajax({
			type: 'get',
			dataType:'json',
			data: {billId:billId},
			url: url,
			success:function(msg){
				if(msg.success == '1'){
            		$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
            		grid.reload();
            	}else{
            		$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
            	}
			}
		});
		
	}
    //格式化时间
    function renderDate2(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            //dateStr = DateUtils.formatDate(date, "yyyy-MM-dd hh:mm");
            dateStr = DateUtils.formatDate(date, "yyyy-MM-dd");
        }
        return dateStr;
    }
    //更新垫款测算结果
    function updateCalcrstCd(){
        var url = '<%=path%>/dk/dkbilldtl/updateCalcrstCd.do';
        var billId = '${billId}';
        $.ajax({
            type: 'get',
            dataType:'json',
            data: {billId:billId},
            url: url,
            success:function(msg){
                if(msg.success == '1'){
                    $.ligerDialog.SQalert({content: '处理成功!',SQ_type: "success"});
                    grid.reload();
                }
            }
        });

    }
    
</script>

<body class="iframeBody">
<div class="Wrapper">
<div id="pageInTab" class="pageInTab">
<div tabid="tabA" title="垫款单明细列表" lselected="true">
<div class="searchArea">
    <form id="searchBar">
        <div class="fieldset1 clearFix">
            <div class="fieldBox">
                <div class="label">问卷结果</div>
                <div class="field">
                    <select name="qtnRstCd" id="qtnRstCd" data-value=" ">
                        <option value=" " seleted>请选择</option>
                        <c:forEach items="${stsCdList}" var="kv">
                            <c:if test="${kv.key == 'DK0010'}">
                                <c:forEach items="${kv.value}" var="kv2">
                                    <option value="${kv2.key }">${kv2.value }</option>
                                </c:forEach>
                            </c:if>
                        </c:forEach>
                    </select>
                </div>
            </div>
            <div class="fieldBox">
                <div class="label">垫款测算结果</div>
                <div class="field">
                    <select name="calcRstCd" id="calcRstCd" data-value=" ">
                        <option value=" " seleted>请选择</option>
                        <c:forEach items="${stsCdList}" var="kv">
                            <c:if test="${kv.key == 'DK0004'}">
                                <c:forEach items="${kv.value}" var="kv2">
                                    <option value="${kv2.key }">${kv2.value }</option>
                                </c:forEach>
                            </c:if>
                        </c:forEach>
                    </select>
                </div>
            </div>
            <div class="fieldBox">
                <div class="label">合同签署状态</div>
                <div class="field">
                    <select name="signStsCd" id="signStsCd" data-value=" ">
                        <option value=" " seleted>请选择</option>
                        <c:forEach items="${stsCdList}" var="kv">
                            <c:if test="${kv.key == 'DK0007'}">
                                <c:forEach items="${kv.value}" var="kv2">
                                    <option value="${kv2.key }">${kv2.value }</option>
                                </c:forEach>
                            </c:if>
                        </c:forEach>
                    </select>
                </div>
            </div>
            <div class="fieldBox">
                <div class="label">垫款状态</div>
                <div class="field">
                    <select name="dtlStsCd" id="dtlStsCd" data-value=" ">
                        <option value=" " seleted>请选择</option>
                        <c:forEach items="${stsCdList}" var="kv">
                            <c:if test="${kv.key == 'DK0005'}">
                                <c:forEach items="${kv.value}" var="kv2">
                                    <option value="${kv2.key }">${kv2.value }</option>
                                </c:forEach>
                            </c:if>
                        </c:forEach>
                    </select>
                </div>
            </div>


            <div class="clearFix"></div>
			<div class="btnsBox formBtns notRight">
                <span id="searchBtn" class="sq-button-round">查询</span>
                <span id="clearBtn" class="sq-button-round">清空</span>
                <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
            </div>
		</div>
	</form>
    </div>
<div id="ligergrid1" class="sq-grid"></div>
</div>
</div>
</div>
</body>
</html>